home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / dev / basic / MethodBBLib.lha / MethodBBLib / Examples / DTSoundExample.asc < prev    next >
Encoding:
Text File  |  1997-03-05  |  2.9 KB  |  141 lines

  1. ;Structures
  2.  
  3. ;***** exec/nodes.h *****
  4.  
  5. NEWTYPE.MinNode
  6.  *mln_Succ.MinNode
  7.  *mln_Pred.MinNode
  8. End NEWTYPE
  9.  
  10. ;***** utility/hooks.h *****
  11.  
  12. NEWTYPE.Hook
  13.  h_MinNode.MinNode
  14.  *h_Entry.l
  15.  *h_SubEntry.l
  16.  *h_Data.b
  17. End NEWTYPE
  18.  
  19. ;***** intuition/classes.h *****
  20.  
  21. NEWTYPE.IClass
  22.  cl_Dispatcher.Hook
  23.  cl_Reserved.l
  24.  *cl_Super.IClass
  25.  *cl_ID.b
  26.  cl_InstOffset.w
  27.  cl_InstSize.w
  28.  cl_UserData.l
  29.  cl_SubclassCount.l
  30.  cl_Flags.l
  31. End NEWTYPE
  32.  
  33. NEWTYPE._Object
  34.  o_Node.MinNode
  35.  *o_Class.IClass
  36. End NEWTYPE
  37.  
  38. ;***** datatypes/soundclass.h *****
  39.  
  40. NEWTYPE.VoiceHeader
  41.  vh_OneShotHiSamples.l
  42.  vh_RepeatHiSamples.l
  43.  vh_SamplesPerHiCycle.l
  44.  vh_SamplesPerSec.w
  45.  vh_Octaves.b
  46.  vh_Compression.b
  47.  vh_Volume.l
  48. End NEWTYPE
  49.  
  50.  
  51. ;Defines
  52.  
  53. ;***** datatypes/datatypesclass.h *****
  54.  
  55. #DTA_Dummy=((1LSL31)+$1000)
  56. #DTA_SourceType=(#DTA_Dummy+101)
  57. #DTA_GroupID=(#DTA_Dummy+31)
  58.  
  59. #DTST_FILE=2
  60.  
  61. #DTM_TRIGGER=($631)
  62.  
  63. #STM_PLAY=2
  64.  
  65. ;***** datatypes/datatypes.h *****
  66.  
  67. #GID_SOUND=$73 6F 75 6E
  68.           ;  s  o  u  n
  69.  
  70. ;***** datatypes/soundclass.h *****
  71.  
  72. #SDTA_Dummy=(#DTA_Dummy+500)
  73. #SDTA_VoiceHeader=(#SDTA_Dummy+1)
  74. #SDTA_Sample=(#SDTA_Dummy+2)
  75. #SDTA_SampleLength=(#SDTA_Dummy+3)
  76. #SDTA_Volume=(#SDTA_Dummy+5)
  77. #SDTA_Cycles=(#SDTA_Dummy+6)
  78.  
  79. ;***** *****
  80.  
  81. NEWTYPE.tags:a.l:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z:End NEWTYPE
  82.  
  83. DEFTYPE.VoiceHeader *vhdr     ;VoiceHeader allows to get infos about sound
  84. DEFTYPE.l sample,samplelength
  85.  
  86. MaxLen name$=120
  87. Dim *args.b(1)
  88.  
  89. ;We read the args
  90.  
  91. rdargs.l=ReadArgs_("/A",&*args(0),0)
  92.  
  93. If rdargs=0           ;No args ???
  94.  NPrint "No Args !!"
  95.  End                  ;YES => End
  96. EndIf
  97.                       ;NO => Continue
  98.                       
  99. name$=Peek$(*args(0)) ;Get the filename from the read args
  100.  
  101. FreeArgs_ rdargs      
  102.  
  103. ;We define the tags for the DTObject creation
  104. ;#DTA_SourceType : #DTST_FILE - The object is a file (it could be ram or
  105. ;clipboard)
  106. ;#DTA_GroupID : #GID_SOUND - We only want a sound (not a picture, a text or
  107. ;an anim
  108. ;#SDTA_Volume : 64 - We set the volume to 64 (maximum)
  109. ;#STDA_Cycles : 1 - Only one time   
  110.  
  111. tags.tags\a=#DTA_SourceType,#DTST_FILE,#DTA_GroupID,#GID_SOUND,#SDTA_Volume,64,#SDTA_Cycles,1,0
  112.  
  113. *o._Object=NewDTObjectA_(&name$,tags) ;We make it
  114.  
  115. If *o=0  ;ERROR ???
  116.  NPrint name$," : DTObject creation failed !!"
  117.  End     ;YES=> End
  118. EndIf
  119.  
  120. attrs.tags\a=#SDTA_VoiceHeader,&*vhdr,#SDTA_Sample,&sample,#SDTA_SampleLength,&samplelength,0
  121.  
  122. ;We get attrs from the DTObject
  123. ;#SDTA_VoiceHeader : &*vhdr - We get the VoiceHeader structure in order to
  124. ;have some infos on the sound (Samples per second ,...)
  125. ;#SDTA_Sample : &sample - We get the sample of the sound in the sample variable
  126. ;#SDTA_SampleLength : &samplelength - The Sample Length !
  127.  
  128. GetDTAttrsA_ *o,attrs
  129.  
  130. a.l=DoMethod(*o,#DTM_TRIGGER,0,#STM_PLAY,0) ;We play the sound
  131.  
  132. length.l=(((samplelength/*vhdr\vh_SamplesPerSec)*50)+50) ;Length of the sound in ticks
  133. lens.f=length/50 ;Length of the sound in seconds
  134. NPrint name$," : ",lens," s" ;Display infos
  135.  
  136. Delay_ length
  137.  
  138. DisposeDTObject_ *o  ;Free the DTObject
  139.  
  140. End ;FINISH !!!
  141.